package com.wxxymaker.service;

import com.blade.ioc.annotation.Bean;
import com.blade.ioc.annotation.Inject;
import com.wxxymaker.model.dao.EmailDao;
import com.wxxymaker.model.entity.Email;
import com.wxxymaker.utils.Const;
import io.github.biezhi.anima.page.Page;

/**
 * @Author: Soft
 * @Date: 2018/7/14 13:45
 * @Desc:
 */
@Bean
public class EmailService {

    @Inject
    private EmailDao dao;

    public Email add(Email email) {
        return dao.add(email);
    }

    public Email delete(int id) {
        return dao.delete(id);
    }

    public boolean change(Email email) {
        return dao.change(email) > 0;
    }

    public Email findOne(int id) {
        return dao.findOne(id);
    }

    public Page<Email> like(String name) {
        return dao.like(name);
    }

    /**
     * 分页查询
     * @param pageNo 页码
     * @param size 每页条数
     * @param status 邮件状态 null全部 0未读 1已读
     * @return page信息
     */
    public Page<Email> page(int pageNo, int size, Integer status) {
        return dao.page(pageNo, size, status);
    }

    public Page<Email> page(int pageNo, Integer status) {
        return this.page(pageNo, Const.shortPageSize, status);
    }

    public Page<Email> page(int pageNo) {
        return this.page(pageNo, null);
    }

    public long count(Integer status) {
        return dao.count(status);
    }
}
